package com.xkstream.client.presenter.kt


import com.xkstream.client.api.LiveApi
import com.xkstream.client.api.LiveService
import com.xkstream.client.base.BaseData
import com.xkstream.client.base.BasePresenterImpl
import com.xkstream.client.entity.kt.GiftStarData
import com.xkstream.client.rx.RxHelper
import com.xkstream.client.rx.RxObserver

/**
 * Created by xiaoyi on 2018-1-9.
 */
class ChatroomPresenter : BasePresenterImpl, ChatroomContract.Presenter {
    lateinit var view: ChatroomContract.View
    lateinit var liveService: LiveService

    constructor(view: ChatroomContract.View) {
        this.view = view
        this.liveService = LiveApi.getInstance().service
        this.view.setPresenter(this)

    }

    override fun getRankGiftStar(params: Map<String, String>) {
        liveService.getRankGiftStar(params)
                .compose(RxHelper.toUI())
                .subscribe(object : RxObserver<BaseData<GiftStarData?>>(this){
                    override fun onSuccess(t: BaseData<GiftStarData?>) {
                        view.showRankGiftStar(t)
                    }

                    override fun onFail(message: String?) {

                    }
                })
    }
}